package cn.stonemind.smu.common.entity;

import cn.stonemind.smu.common.entity.constant.ResponseConstant;

import java.util.HashMap;

public class SmuResponse extends HashMap<String, Object> {

    public SmuResponse message(String status, String message) {
        this.put("status", status);
        this.put("message", message);
        return this;
    }

    public SmuResponse success() {
        return this.message(ResponseConstant.SUCCESS_CODE, ResponseConstant.SUCCESS_MESSAGE);
    }

    public SmuResponse success(String message) {
        return this.message(ResponseConstant.SUCCESS_CODE, message);
    }

    public SmuResponse error() {
        return this.message(ResponseConstant.ERROR_CODE, ResponseConstant.ERROR_MESSAGE);
    }

    public SmuResponse error(String message) {
        return this.message(ResponseConstant.ERROR_CODE, message);
    }

    public SmuResponse error(String code, String message) {
        return this.message(code, message);
    }

    public SmuResponse result(Object result) {
        SmuResponse res = this.success();
        res.put("result", result);
        return res;
    }

}
